<?php


	function get_project_categories(){
		$args = array(
		 'orderby'       => 'name',
		  'hierarchical'  => true,
		  'hide_empty'    => true
		);
		$categories = get_terms( 'dmci_project_categories', $args );
		
		return $categories;
	}
	
	
	function get_project_locations(){
		$args = array(
		 'orderby'       => 'name',
		  'hierarchical'  => true,
		  'hide_empty'    => true
		);
		$locations = get_terms( 'dmci_project_locations', $args );
		
		return $locations;
	}
	
	function search_projects($taxonomy, $slug, $posts = false, $post_type = 'dmci_projects'){
	
		$args = array(
					'post_type' => $post_type,
					'tax_query' => array(
						array(
							'taxonomy' => $taxonomy,
							'field' => 'slug',
							'terms' => $slug
						)
					)
				);
				
		if($posts) {
			$args['posts_per_page'] = $posts;
		}
		$query = new WP_Query( $args );
		
		return $query;
		
	}
	
	
